﻿@{
    Layout = null;
}
@model System.Collections.IEnumerable
<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head>

@if (false)
{
    <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script> 
    <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>     
}

<link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>
<script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

@Html.DevExpress().GetStyleSheets(
        new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }
)
@Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)


<script type="text/javascript">

    $(function () {
        $("#toolMenu").smartFloat();
    });

    function OnBeginCallback(s, e) {
        e.customArgs["command"] = e.command;
        e.customArgs["pageIndex"] = s.pageIndex;
        e.customArgs["pageCount"] = s.pageCount;
        e.customArgs["pageRowSize"] = s.pageRowSize;
        e.customArgs["pageRowCount"] = s.pageRowCount;
        e.customArgs["albumClsNo"] = $('#hdalbumClsNo').val();

    }



    function MenuTop_emClick(source, e) {
//        var dirId = $('#hidDirId').val();
//        if (dirId != "") {
//            dirId = parseInt(dirId);
//        } else {
//            dirId = 0;
        //        }
        var albumClsNo = $('#hdalbumClsNo').val();
        switch (e.item.name) {
            case "btnAlbum":
                {
                    //新建相册
                    if (albumClsNo=="") {
                        alert("请选择具体的相册类别")
                    } else {
                        //albumModalMode.SetContentUrl("/Admin/DocManager/AlbumAdd?dirID=" + dirId);
                        $('#albumContent').attr("src", rootPath + "/Admin/Album/AlbumAdd?albumClsNo=" + albumClsNo);
                        albumModalMode.Show();
                    }
                    break;
                }
        }
    }


    function albumModalModeOK(type) {
        alert("保存成功");
        if (type == "add") {
            window.location.href = rootPath + "/Admin/Album/AlbumList?albumClsNo=" + $('#hdalbumClsNo').val();
        } else if (type == "edit") {
            gvEditing.Refresh();
        }
        albumModalMode.Hide();
    }


    function albumModalModeCancel() {
        albumModalMode.Hide();
    }


    function edit(albumId, albumClsNo) {
        $('#albumContent').attr("src", rootPath + "/Admin/Album/AlbumAdd?albumClsNo=" + albumClsNo + "&albumId=" + albumId);
        albumModalMode.Show();

    }

    function del(albumId, albumClsNo) {
        if (confirm("确定删除?")) {
            $.ajax({
                type: 'POST',
                url: rootPath + '/Admin/Album/DocDel',
                data: { albumId: albumId, albumClsNo: albumClsNo, type: "ALBUM" },
                success: function (result) {
                    if (result == "ok") {
                        alert("删除成功");
                        gvEditing.Refresh();
                    } else {
                        alert(result);
                    }
                }
            });
        }
    }

    function SetModel() {
        lpLoad.Show();
    }


</script>

</head>

<body>

<div class="floatToolMenu" id="toolMenu">
       @Html.DevExpress().Menu(settings =>
  {
      settings.Name = "toolBarMenu";
      settings.ItemAutoWidth = false;
      settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
      settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
      settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

      settings.Items.Add(item =>
      {
          item.Name = "btnAdd";
          item.Text = "新建";
          item.ClientEnabled = true;
          item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");
          item.Items.Add(childItem =>
          {
              childItem.Name = "btnAlbum";
              childItem.Text = "相册";
              childItem.ClientEnabled = true;
              childItem.Image.Url = Url.Content("~/Content/ControlImages/pictures.png");
          });

      });
      //settings.Items.Add(item =>
      //{
      //    item.Name = "btnSort";
      //    item.Text = "排序";
      //    item.Visible = (bool)ViewData["FW"];
      //    item.ClientEnabled = true;
      //    item.Image.Url = Url.Content("~/Content/ControlImages/sort.png");

      //});
      settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
      settings.ItemLinkMode = ItemLinkMode.ContentBounds;
  }).GetHtml()
        </div>

@Html.Hidden("hdalbumClsNo", ViewData["albumClsNo"])
@Html.Partial("AlbumListPartial", Model)



@Html.DevExpress().PopupControl(
    settings =>
    {
        settings.Name = "albumModalMode";
        settings.Width = 600;
        settings.Height = 430;
        settings.AllowDragging = true;
        settings.CloseAction = CloseAction.CloseButton;
        settings.EnableAnimation = false;
        settings.HeaderText = "相册";
        settings.Modal = true;
        settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
        settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
        settings.ShowFooter = true;
        settings.SetFooterTemplateContent(s =>
        {
            ViewContext.Writer.Write("<table align='center'><tr><td>");
            Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnAlbumOK";
                footBtnSettings.Text = "确定";
                footBtnSettings.ClientSideEvents.Click = "function(s,e){albumContent.Save()}";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td><td>");
            Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnAlbumCancel";
                footBtnSettings.Text = "取消";
                footBtnSettings.ClientSideEvents.Click = "albumModalModeCancel";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td></tr></table>");

        });
        settings.SetContent(() =>
        {
            ViewContext.Writer.Write("<iframe  id='albumContent' name='albumContent' style='width:600px;height:330px' frameborder='0' ></iframe>");
        });
    }).GetHtml()


@Html.DevExpress().LoadingPanel(settings =>
    {
        settings.Name = "lpLoad";
        settings.Modal = true;
        settings.Text = "数据读取中...";
    }).GetHtml()

<script>
    lp.Hide();
</script>
</body>

</html>